package basic;

public class Method {

    public static void main(String[] args) {
        Person ming = new Person();
        ming.setName("wangjh");
        ming.age=26;
        System.out.println(ming.toString());
    }

}


class Person{
    protected String name ;
    public int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {

        if (name==null || name.isEmpty()){
            throw new IllegalArgumentException();
        }
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}